home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg1.cab / Functions.xba < prev    next >
Extensible Markup Language  |  2005-09-26  |  11KB  |  370 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Functions" script:language="StarBasic">REM  *****  BASIC  *****
  4. Dim DialogVisible As Boolean
  5. Dim TutorStep As Integer
  6. Dim TutorLastStep As Integer
  7. Dim myDialog As Object
  8. Dim myTutorial As Object
  9. Public TutorText() As String
  10. Dim documentTitle As String
  11. Dim exampleUse As Object     
  12. Dim properties() As Object
  13. Dim docTYP  As String
  14. 'public myWidth As Long
  15. Dim myHeight As Long
  16. Dim oTextField As Object
  17. Dim stepTitle  As String
  18. Dim oOpenDialogFlag
  19. Dim imageStatus  As String
  20.  
  21. Sub LoadTutorialDialog(exampleToUse, documentTYP)
  22.     Init()
  23.     exampleUse = exampleToUse
  24.     TutorText() = exampleUse.LoadText()    
  25.     properties() = exampleUse.GetProperties()
  26.     If properties(3).Value = "True" Then
  27.         Dim localisation(0) As new com.sun.star.beans.NamedValue
  28.         localisation(0).Name = "Localisation"
  29.         localisation(0).Value = properties()
  30.         myTutorial.execute(localisation())
  31.     Else
  32.         TutorStep = 0
  33.         TutorLastStep = 0
  34.         docTYP = documentTYP
  35.         InitAction()
  36.         ShowInfoMain()    
  37.         DialogVisible = True
  38.         myDialog = LoadDialog("Tutorials","TutorialsDialog")    
  39.         
  40.         SetTutorialDocumentPosSize()
  41.         
  42.         documentInfo =  ThisComponent.getDocumentInfo()
  43.         myDialog.Title = "Tutorials - " & documentInfo.Title
  44.         oTextField = myDialog.GetControl("myTextField")
  45.         oTextField.setVisible(False)
  46.         
  47.         imageStatus = "MIN"        
  48.         setMaxMinImage(imageStatus)
  49.         
  50.         'myWidth = myDialog.Size.Width
  51.         myHeight = myDialog.Size.Height
  52.         
  53.         CheckForStepShowButtonStatus()
  54.         CheckForStepNextButtonStatus()
  55.         InitRoadMap()        
  56.         SetVisibleTrue()
  57.         myDialog.model.myTextField.Label = stepTitle
  58.         myDialog.model.myText.Label = GetStepText()'TutorText(TutorStep)
  59.                 
  60.         
  61.         Do
  62.             wait 1000
  63.         Loop Until DialogVisible = False
  64.         If( oOpenDialogFlag = True) Then
  65.             Destroy()
  66.             TutorialOpen.TutorialOpenMain()        
  67.         Else 
  68.             Destroy()
  69.         End If                
  70.     End If
  71. End Sub
  72.  
  73. Sub setMaxMinImage(param As String)
  74.     On Local Error Goto NOIMAGE
  75.         oCommandButton = myDialog.GetControl("CommandButton")
  76.         templatePath = GetPathSettings("Template",false, 0)
  77.         Dim bitmapPath As String
  78.         iPos = InStr(templatePath,"/")
  79.         If(iPos > 0) Then
  80.             If(param = "MAX") Then
  81.                 bitmapPath = templatePath & "/wizard/bitmap/maximize.bmp"
  82.             ElseIf(param = "MIN") Then    
  83.                 bitmapPath = templatePath & "/wizard/bitmap/minimize.bmp"
  84.             End If
  85.         Else
  86.             If(param = "MAX") Then
  87.                 bitmapPath = templatePath & "\wizard\bitmap\maximize.bmp"
  88.             ElseIf(param = "MIN") Then    
  89.                 bitmapPath = templatePath & "\wizard\bitmap\minimize.bmp"
  90.             End If        
  91.         End If
  92.         'printdbgInfo oCommandButton.Model
  93.         oCommandButton.Model.ImageUrl = bitmapPath
  94.     Exit Sub    
  95.     NOIMAGE:        
  96. End Sub
  97.  
  98. Sub SetTutorialDocumentPosSize()
  99.     activDesktopWindow = StarDesktop.activeFrame.ContainerWindow
  100.     If(activDesktopWindow.posSize.Height < 550) Then
  101.         activDesktopWindow.setPosSize(0,0,0,550,8)
  102.     End If    
  103.     If    (activDesktopWindow.posSize.Width < 750 ) Then
  104.         activDesktopWindow.setPosSize(0,0,750,0,4)
  105.     EndIf    
  106. End Sub
  107.  
  108. Sub InitRoadMap()
  109.     RoadMapMain(Functions, myDialog)
  110.     SetControlModelPosSize(0, 0, 85, 176)
  111.     SetControlModelText("Steps")
  112.     
  113.     StepSize = Ubound(TutorText())
  114.     Dim ItemsArray(StepSize) as String
  115.     For i = 0 To StepSize        
  116.         stepcontent = TutorText(i)
  117.         iPos = InStr(stepcontent,CHR(13))
  118.         ItemName = Left(stepcontent, iPos)
  119.         ItemsArray(i) = ItemName
  120.     Next i
  121.     InsertItemsLabels( ItemsArray())
  122.     
  123.     For i = 1 To StepSize            
  124.         SetItemEnabled( i, False)            
  125.     Next i
  126.     SetItemEnabled( 0, True)
  127. End Sub
  128.  
  129. Sub Destroy()
  130.     'myDialog.dispose        
  131.     wait 1000                
  132.     ShowInfoDialog.DisposeIDialog()
  133.     
  134.     ' HIER WIRD DAS DOCUMENT GESCHLOSSEN!!!!!!!! GPF
  135.     thisComponent.CurrentController.Frame.close(True)    
  136.     
  137. End Sub
  138.  
  139. Sub Init
  140.     GlobalScope.BasicLibraries.LoadLibrary("Tools")    
  141.     myTutorial = createUNOService("com.sun.star.wizards.tutorial.executer.CallTutorialFramework")
  142.     documentTitle = ThisComponent.getCurrentController.getFrame.Title    
  143. End Sub
  144.  
  145. Sub InitStep
  146.     userFieldName = ThisComponent.getDocumentInfo.getUserFieldName(0)
  147.     ResultString = InStr (userFieldName, "CurrentStep:")
  148.     If ResultString <> 0 Then
  149.         TutorStep = Val(ThisComponent.getDocumentInfo.getUserFieldValue(0))
  150.     Else
  151.         ThisComponent.getDocumentInfo.setUserFieldName(0, "CurrentStep:")
  152.         ThisComponent.getDocumentInfo.setUserFieldValue(0, TutorStep)
  153.     End If 
  154. End Sub
  155.  
  156. Sub setStep
  157.     ThisComponent.getDocumentInfo.setUserFieldValue(0, TutorStep)
  158. End Sub
  159.  
  160. Sub InitAction()
  161.     SetStepTitle()
  162.         
  163.     Dim property(6) As new com.sun.star.beans.PropertyValue    
  164.     property(0).Name = "DocumentTYP"
  165.     property(0).Value = docTYP    
  166.     property(1).Name = "MethodName"
  167.     property(1).Value = "setDelay"    
  168.     property(2).Name = "Param"
  169.     property(2).Value = 0     'key insert speed (Millis)
  170.     property(3).Name = "Param"
  171.     property(3).Value = 4     'mouse animate speed (Millis)
  172.     property(4).Name = "Param"
  173.     property(4).Value = 2000 'after mouse animate sleep (Millis)
  174.     property(5).Name = "Param"
  175.     property(5).Value = 10     'mouse scroll speed (Millis)
  176.     property(6).Name = "Param"
  177.     property(6).Value = -1     'mouse speed (step)
  178.     myTutorial.setPropertyValues(property())
  179. End Sub
  180.  
  181. Sub EndDialog
  182.     oOpenDialogFlag = False    
  183.     If (myDialog.model.done.Label = "Close") Then
  184.         TutorialCloseMain()
  185.     Else 
  186.         DialogVisible = False        
  187.     End If
  188. End Sub
  189.  
  190. Sub NextStep
  191.     GotoStep(TutorStep + 1)    
  192. End Sub
  193.  
  194. Sub GotoStep(StepIndex)
  195.     If(StepIndex <= Ubound(TutorText())) Then    
  196.         TutorStep = StepIndex
  197.         If TutorStep > TutorLastStep Then
  198.             TutorLastStep = TutorStep
  199.         End If        
  200.         If(TutorStep = Ubound(TutorText())) Then
  201.             myDialog.model.next.enabled = False
  202.             myDialog.model.done.Label = "Done"
  203.             myDialog.model.show.Label = "Tutorials"    
  204.         Else
  205.             myDialog.model.next.enabled = True     
  206.         End If
  207.         SetStepTitle()
  208.         myDialog.model.myText.Label = GetStepText()
  209.         CheckForStepShowButtonStatus()    
  210.         SetItemEnabled( TutorStep, True)
  211.         'setStep()
  212.     End If
  213. End Sub
  214.  
  215. Function GetStepText()
  216.     Dim tempText As String
  217.     tempText = TutorText(TutorStep)
  218.     iPos = InStr(tempText,CHR(13))
  219.     ResultString = Right(tempText, Len(tempText) - iPos - 1)
  220.     GetStepText() = ResultString
  221. End Function
  222.  
  223. Sub ItemChange(CurrentItemID, SelectitemID)
  224.     GotoStep(SelectitemID)
  225. End Sub
  226.  
  227. Sub SetDisableShowMeButton()
  228.     myDialog.model.show.enabled = False    
  229.     TutorLastStep = TutorLastStep + 1
  230. End Sub
  231.  
  232. Sub Minimize(aEvent)
  233.     ActionItemsTextField = myDialog.GetControl("ActionItemsLabel")
  234.     FixedLineVertikal = myDialog.GetControl("FixedLineVertikal")
  235.     
  236.     If myDialog.Size.Height = 35 Then
  237.         myDialog.setPosSize(0,0,0,myHeight,8)
  238.         oTextField.setVisible(False)
  239.         ActionItemsTextField.setVisible(True)
  240.         FixedLineVertikal.setVisible(True)
  241.         RoadMap.SetVisibleRoadMap(True)
  242.     Else
  243.         myDialog.setPosSize(0,0,0,35,8)
  244.         rmSelectedIndex = RoadMap.GetSelectedIndex() + 1
  245.         gsTitle = GetStepTitle()        
  246.         oTextField.setText(rmSelectedIndex & ". " & gsTitle)
  247.         oTextField.setVisible(True)
  248.         ActionItemsTextField.setVisible(False)
  249.         FixedLineVertikal.setVisible(False)
  250.         RoadMap.SetVisibleRoadMap(False)
  251.     End If
  252.     If(imageStatus = "MAX") Then
  253.         imageStatus = "MIN" 
  254.     ElseIf(imageStatus = "MIN") Then    
  255.         imageStatus = "MAX"
  256.     End If
  257.     setMaxMinImage(imageStatus)
  258.  
  259. End Sub
  260.  
  261. Sub SetStepTitle()
  262.     stepcontent = TutorText(TutorStep)
  263.     iPos = InStr(stepcontent,CHR(13))
  264.     stepTitle = Left(stepcontent, iPos)
  265.     SetStepTitle() = stepTitle
  266. End Sub
  267.  
  268. Function GetStepTitle()
  269.     GetStepTitle() = stepTitle
  270. End Function
  271.  
  272. Sub CheckForStepShowButtonStatus()
  273.     If ((exampleUse.ContainsStepAction() = True And TutorStep = TutorLastStep) Or myDialog.model.show.Label = "Tutorials") Then
  274.         myDialog.model.show.enabled = True            
  275.     Else
  276.         myDialog.model.show.enabled = False
  277.     End If
  278. End Sub
  279.  
  280. Sub CheckForStepNextButtonStatus()
  281.     If(TutorStep = Ubound(TutorText())) Then
  282.         myDialog.model.next.enabled = False
  283.         myDialog.model.done.Label = "Done"
  284.     End If
  285. End Sub
  286.  
  287. Sub Show(aEvent)
  288.     'ShowInfoMain()
  289.     If( myDialog.model.show.Label = "Tutorials") Then
  290.         oOpenDialogFlag = True
  291.         DialogVisible = False
  292.     Else 
  293.         SetMousePosition(aEvent)
  294.         exampleUse.Action() 
  295.     End If    
  296. End Sub
  297.  
  298. Sub SetMousePosition(aEvent)
  299.     MyPoints() = MousePoints(aEvent)
  300.     
  301.     Dim mousePosition(3) as new com.sun.star.beans.PropertyValue
  302.     mousePosition(0).Name = "DocumentTYP"
  303.     mousePosition(0).Value = docTYP    
  304.     mousePosition(1).Name = "MethodName"
  305.     mousePosition(1).Value = "setMousePosition"           
  306.        mousePosition(2).Name = "Param"
  307.        mousePosition(2).Value = MyPoints(0)       
  308.     mousePosition(3).Name = "Param"
  309.     mousePosition(3).Value = MyPoints(1)
  310.             
  311.     myTutorial.setPropertyValues(mousePosition())    
  312. End Sub
  313.  
  314. Function MousePoints(aEvent)
  315.     Dim position(1) As Integer
  316.     position(0) = myDialog.getControl("show").AccessibleContext.LocationOnScreen.X + aEvent.Source.Model.PositionX    
  317.     position(1) = myDialog.getControl("show").AccessibleContext.LocationOnScreen.Y + aEvent.Source.Model.PositionY
  318.     MousePoints = position()    
  319. End Function
  320.  
  321. Function CheckPath(path() As String)        
  322.     'documentTitle = ThisComponent.getCurrentController.getFrame.Title
  323.     sTitle =  path(0)    
  324.     ResultString = Right(sTitle, 3)
  325.     iPos = InStr(ResultString,"#")
  326.     ResultString = Right(ResultString, Len(ResultString) - iPos)
  327.     ResultFrameString = InStr (sTitle, "{D}FRAME#")
  328.     If ResultFrameString <> 0 Then
  329.         If Not (sTitle = ("{D}FRAME#" & documentTitle & "#" & ResultString)) Then
  330.             'path(0) = "{D}FRAME#" & documentTitle & "#" & ResultString
  331.             path(0) = "FRAME#" & documentTitle & "#" & ResultString
  332.             sTitle =  path(1)    
  333.             ResultString = Right(sTitle, 3)
  334.             iPos = InStr(ResultString,"#")
  335.             ResultString = Right(ResultString, Len(ResultString) - iPos)
  336.             path(1) = "ROOT_PANE#" & documentTitle & "#" & ResultString
  337.         Else
  338.             'path(0) = "{D}FRAME#" & documentTitle & "#" & ResultString    
  339.             path(0) = "FRAME#" & documentTitle & "#" & ResultString    
  340.         End If
  341.     End If    
  342. End Function
  343.  
  344. Sub SetVisibleTutorialsDialog(param)
  345.     myDialog.setVisible(param)
  346. End Sub
  347.  
  348. Sub SetVisibleTrue()
  349.     myDialog.setVisible(True)
  350. End Sub
  351.  
  352. Sub SetVisibleFalse()
  353.     myDialog.setVisible(False)
  354. End Sub
  355.  
  356. Sub ExitTutorial()        
  357.     Dim aUrl As new com.sun.star.util.URL
  358.     oDoc = ThisComponent
  359.     urlTransformer = createUNOService("com.sun.star.util.URLTransformer")
  360.     aUrl.Complete = "slot:5621"
  361.     urlTransformer.parseStrict(aUrl)
  362.     xController = oDoc.getCurrentController()
  363.     xDispatcher = xController.queryDispatch(aUrl, "", 0)
  364.     if NOT isNull(xDispatcher) then
  365.         xDispatcher.dispatch(aUrl, DimArray())
  366.      else
  367.        msgBox "Error! Cannot close document."
  368.      End If     
  369. End Sub
  370. </script:module>